feat(trezor): add account info, compose, and broadcast FFI exports#75
feat(trezor): add account info, compose, and broadcast FFI exports#75coreyphillips wants to merge 17 commits intomasterfrom
Conversation
# Conflicts: # Cargo.lock # Cargo.toml # Package.swift # bindings/android/gradle.properties # bindings/android/lib/src/main/jniLibs/arm64-v8a/libbitkitcore.so # bindings/android/lib/src/main/jniLibs/armeabi-v7a/libbitkitcore.so # bindings/android/lib/src/main/jniLibs/x86/libbitkitcore.so # bindings/android/lib/src/main/jniLibs/x86_64/libbitkitcore.so # bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt # bindings/ios/BitkitCore.xcframework.zip # bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/libbitkitcore.a # bindings/ios/BitkitCore.xcframework/ios-arm64/libbitkitcore.a # bindings/python/bitkitcore/libbitkitcore.dylib
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
I've went over parts of the code, but have a few bigger and a bit more general points I'd like to understand/ address first:
|
…pt-based lookups, and coinbase detection - Reuse single Electrum client for block height and wallet sync - Replace sequential script_get_history calls with BDK LastUnused boundary - Use HashMap<ScriptBuf, String> for direct UTXO path lookups - Add proper coinbase detection via is_coin_base() - Add script_type override for ambiguous xpub/tpub prefixes
|
Regarding the items above:
|
…ped coin enum - Replace unwrap_or(0) with proper error propagation for amount parsing in precomposed_to_sign_params to prevent silent 0-value outputs - Change TrezorPrecomposeParams.coin from String to Option<TrezorCoinType> to eliminate invalid coin name bugs - Activate network validation in get_address_info to catch address/network mismatches
- Updates bindings - Bumps version to 0.1.46
- Updates bindings - Bumps version to 0.1.47
|
Ok thanks. About 3, maybe we should at least leave a TODO comment to make sure we update to use BDK and the coin selection algo of the user's choice? |
|
So I tried looking into it a bit more, but still I don't understand why use the Trezor compose part? I think it would be best to compose the transaction using BDK, which is very simple, will work for any hardware or watch only wallet (reducing Trezor specific code), and will allow preserving UTXO selection algorith. Then we just pass the BDK generated PSBT to the sign_tx_from_psbt for signing. |
|
I've made a vibe coded attempt to just use BDK over trezor compose, and code seems significantly shorter, usable for future integrations, and can support BDK coin selection algos. Can you see if this approach would make sense @coreyphillips ? Made it a draft here #78 |
Nice! I think that would be a good approach. I'm just fixated on integrating trezor-connect-rs, but utilizing BDK for this in bitkit-core makes a lot of sense. How would you like to proceed? Shall we review the draft and merge it in here once good? |
|
Sure, I'll push some updates then so it's ready for review |
…nd clean up types
BDK copose PSBT
|
@coreyphillips Bindings need to be regenerated?! (I'm pretty sure the answer is yes). We should probably feel free to merge #76 and bump version higher than that one. Version bump was the only reason I actually suggested merging that PR after this one. EDIT: NVM, I just merged that PR so we can merge master in here, bump version and regenerate the bindings 🙏🏻 |
- Updates bindings - Bups version to 0.1.48
# Conflicts: # Cargo.lock # Cargo.toml # Package.swift # bindings/android/gradle.properties # bindings/android/lib/src/main/jniLibs/arm64-v8a/libbitkitcore.so # bindings/android/lib/src/main/jniLibs/armeabi-v7a/libbitkitcore.so # bindings/android/lib/src/main/jniLibs/x86/libbitkitcore.so # bindings/android/lib/src/main/jniLibs/x86_64/libbitkitcore.so # bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt # bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.common.kt # bindings/ios/BitkitCore.xcframework.zip # bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/libbitkitcore.a # bindings/ios/BitkitCore.xcframework/ios-arm64/libbitkitcore.a # bindings/ios/bitkitcore.swift # bindings/python/bitkitcore/bitkitcore.py # bindings/python/bitkitcore/libbitkitcore.dylib # src/lib.rs
|
Regenerating the bindings after merge now. Will ping you here once complete. |
ben-kaufman
left a comment
There was a problem hiding this comment.
lgtm as first step, will need to work on tx history and events later
This PR:
account_infomodule with BDK/Electrum queries (no device required)composemodule bridging bitkit-core account types to trezor-connect-rs offline coin selectionfetch_prev_txsto retrieve previous transactions needed for non-SegWit signingbroadcast_raw_txto broadcast signed transactions via ElectrumAccountInfoErrorerror type for blockchain query operationsScriptTypeconversion and compose FFI types(
TrezorFeeLevel,TrezorSortingStrategy,TrezorPrecomposeOutput,TrezorPrecomposeParams,TrezorPrecomposedInput,TrezorPrecomposedOutput,TrezorPrecomposedResult)New FFI exports
trezor_get_account_infotrezor_get_address_infotrezor_account_type_to_script_typetrezor_precompose_transactiontrezor_precomposed_to_sign_paramstrezor_fetch_prev_txstrezor_broadcast_raw_tx